const app = getApp()


import {
    selfFormatTimeYMD,
    selfFormatTimeHM,
    twoTimeIntervalReturnHours,
    twoTimeInterval
} from "../../../../../utils/util.js"

import {
    selectShowroomRecordByIdRq
} from "../../../../../api/meeting/exhibition.js"

Page({

    /**
     * 页面的初始数据
     */
    data: {
        IMG_NAME: app.IMG_NAME,
        id: null,
        detail: null,
        personList: [],
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        let _this = this;
        _this.setData({
            ...options
        })
        // 获取详情
        _this.getDetail();
    },

    // 获取详情
    getDetail() {
        let _this = this;
        let id = _this.data.id;
        selectShowroomRecordByIdRq(id).then(res => {
            let detail = res.data;
            // 时间段
            detail.timeSlot = selfFormatTimeYMD(detail.startTime) + ' ' + selfFormatTimeHM(detail.startTime) + '~' + selfFormatTimeHM(detail.endDate);
            // 合计时间
            detail.countTime = twoTimeInterval(detail.startTime, detail.endDate)
            // 颜色
            let color = "#3794FF"
            if (detail.status == 0) { // 待审核
                color = "#3794FF"
            } else if (detail.status == 1) { // 审核通过
                color = "#62c855"
            } else if (detail.status == 4) { // 审核驳回
                color = "#7F7F7F"
            }
            detail.statusColor = color;
            // persons
            let persons = detail.persons;
            let personList = []
            if (persons) {
                personList = JSON.parse(persons);
            }
             // 图片
             if (detail.indoorPicUrl) {
                try {
                    detail.indoorPicUrlFirst = JSON.parse(detail.indoorPicUrl)[0].url
                } catch (error) {
                    console.log(`JSON error : ${error}`);
                }
            }
            //
            _this.setData({
                detail,
                personList,
            })
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage(e) {
        console.log('onShareAppMessage', e);
    }

})